;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Wc3 Gradient Generator
;  By: h3ih02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Installing:
;  1) Save this file to your hard drive
;  2) Open mIRC and hit alt+r
;  3) Hit ctrl+l and load the file
;     Or
;  1) Open mIRC and hit alt+r
;  2) Hit alt+f and go to New
;  3) Paste everything here there
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Usage:
;  1) Type /wc3grad in the editbox
;  2) Change the text to whatever you want
;  3) Change the start and end RGB
;  4) Preview the gradient to see if it is what you want
;  5) Hit generate
;  6) Copy everything from the large editbox to WE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Note:
;  In the preview window you can right click to change the background color(if a character in the text is the same color as the background, it will change too)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dialog wc3grad {
  title "WC3 Gradient Generator"
  size -1 -1 130 72
  option dbu
  edit "0", 1, 30 10 16 10, limit 3 center
  edit "0", 2, 46 10 16 10, limit 3 center
  edit "0", 3, 62 10 16 10, limit 3 center
  edit "0", 4, 30 20 16 10, limit 3 center
  edit "0", 5, 46 20 16 10, limit 3 center
  edit "0", 6, 62 20 16 10, limit 3 center
  edit "Text", 7, 30 0 100 10, autohs
  text "Start Color:", 8, 0 11 30 8, right
  text "Text:", 9, 0 1 30 8, right
  text "End Color:", 10, 0 21 30 8, right
  edit "", 11, 0 30 130 30, read multi autovs
  button "Generate", 12, 92 18 37 12
  button "Preview", 13, 0 60 37 12
  button "Ok", 14, 93 60 37 12, ok
}
alias wc3grad dialog $iif($dialog(wc3grad),-v,-md) wc3grad wc3grad
on *:DIALOG:wc3grad:*:*:{
  if ($devent == EDIT) {
    if ($did isnum 1-6) {
      if ($did($dname,7)) && ($did($dname,1) isnum 0-255) && ($did($dname,2) isnum 0-255) && ($did($dname,3) isnum 0-255) && ($did($dname,4) isnum 0-255) && ($did($dname,5) isnum 0-255) && ($did($dname,6) isnum 0-255) { if (!$did($dname,12).enabled) did -e $dname 12,13 }
      elseif ($did($dname,12).enabled) did -b $dname 12,13
    }
  }
  elseif ($devent == SCLICK) {
    if ($did == 12) {
      var %a 1,%l $len($did($dname,7)) - 1,%s,%r $did($dname,1),%g $did($dname,2),%b $did($dname,3)
      while $mid($did($dname,7),%a,1) {
        if ($v1 != $chr(32)) var %s $+(%s,|c00,$base(%r,10,16,2),$base(%g,10,16,2),$base(%b,10,16,2),$v1,|r),%r %r + $int($calc(($did($dname,4) - $did($dname,1)) / %l)),%g %g + $int($calc(($did($dname,5) - $did($dname,2)) / %l)),%b %b + $int($calc(($did($dname,6) - $did($dname,3)) / %l))
        inc %a
      }
      did -ra $dname 11 %s
    }
    elseif ($did == 13) {
      window -adfpk0 @Preview $mouse.dx $mouse.dy $width($did($dname,7),12,Tahoma,1) $height($did($dname,7),12,Tahoma) @Preview
      drawrect -rnf @Preview 0 1 0 0 $window(@Preview).w $window(@Preview).h
      var %a 1,%l $len($did($dname,7)) - 1,%x 0,%r $did($dname,1),%g $did($dname,2),%b $did($dname,3)
      while $mid($did($dname,7),%a,1) {
        if ($v1 != $chr(32)) {
          drawtext -rno @Preview $rgb(%r,%g,%b) Tahoma 12 %x 0 $v1
          var %x %x + $width($v1,12,Tahoma,1),%r %r + $int($calc(($did($dname,4) - $did($dname,1)) / %l)),%g %g + $int($calc(($did($dname,5) - $did($dname,2)) / %l)),%b %b + $int($calc(($did($dname,6) - $did($dname,3)) / %l))
        }
        else inc %x $width($chr(32),12,Tahoma,1)
        inc %a
      }
      drawdot @Preview
    }
  }
}
menu @Preview {
  Background:{
    while (%r !isnum 0-255) var %r $?="Red Value:"
    while (%g !isnum 0-255) var %g $?="Green Value:"
    while (%b !isnum 0-255) var %b $?="Blue Value:"
    drawreplace -r @Preview $getdot(@Preview,0,0) $rgb(%r,%g,%b)
  }
}